<?php
include_once "../header1.php";
?>

<link href="../style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
require_once '../Login/databaseconnection.php';
if(!loggedin())
{
require_once '../index.php';
}
   
   else
   {
 if(isset($_POST['Search']))
	   {
	  $Resource_Id=$_POST['Resource_Id'];
$Lab_Id=$_POST['Lab_Id'];
	  
	   if($Resource_Id=="Select One"||$Lab_Id=="Select One")
	   {
		   $_SESSION['errorin1']="Please select the Resource id and Lab id!";
	   
	   }
	   else
	   {
	     $result=mysql_query("SELECT * FROM resource_details WHERE Resource_Id='$Resource_Id' AND Lab_Id='$Lab_Id'");
		
	   if(mysql_num_rows($result)==0)
   {
	   $_SESSION['errornorow']="Very sorry there is no result,Please check your input and try again!";
   }
   }
   }
   ?>

<?php
include_once "../header2.php";
?>
<?php
include_once "topmenu.php";
?> 
<div class="left">
  
<div class="articles">
 <form action="#" method="POST">
 <table width="739" border="0" class="tablefontv">
      <tr>
        <td height="18" colspan="7" align="left" scope="row"><?php
		if(isset($_POST['Search']))
{
	if(isset($_SESSION['errorin1']))
	{
		echo $_SESSION['errorin1'];
		unset($_SESSION['errorin1']);
	}
	if(isset($_SESSION['errornorow']))
	{
		echo $_SESSION['errornorow'];
		unset($_SESSION['errornorow']);
	}
}
		?></td>
        </tr>
      <tr>
        <td width="96" rowspan="3" align="left" scope="row" bgcolor="#6AB5FF">Search by</td>
      <td width="97" height="30" align="left" scope="row" bgcolor="#6AB5FF">Resource Id</td>
      <th width="8" align="left" scope="row" bgcolor="#6AB5FF">:-</th>
      <td colspan="2" bgcolor="#999999"><select name="Resource_Id" id="select">
	   <?php
	  
	  if(isset($_POST['Search']))
	  {
	echo '<option value="'.$Resource_Id.'">'.$Resource_Id.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	  ?>
      <?php
	  $res=mysql_query("SELECT DISTINCT(Resource_Id) FROM resource_details");
	  
  while($row=mysql_fetch_array($res))
  {
	  $Resource_Id=$row['Resource_Id'];
	  echo '<option value="'.$Resource_Id.'">'.$Resource_Id.'</option>';
  }
	  ?>
     
      </select></td>
      <td width="80" rowspan="2" bgcolor="#6AB5FF">Other Way:</td>
      <td width="261" rowspan="2" bgcolor="#999999"><table width="224" border="1">
        <tr>
          <td><input type="text" name="textfield" />
            <input name="SearchOther" align="middle" type="submit" value="Search" /></td>
        </tr>
      </table></td>
      </tr>
    <tr>
      <td align="left" scope="row" bgcolor="#6AB5FF">Lab Id</td>
      <th width="8" align="left" scope="row" bgcolor="#6AB5FF">:-</th>
      <td colspan="2" bgcolor="#999999"><select name="Lab_Id" id="select">
        <?php
	  
	  if(isset($_POST['Search']))
	  {
	echo '<option value="'.$Lab_Id.'">'.$Lab_Id.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	  ?>
        <?php
	  $res=mysql_query("SELECT DISTINCT(Lab_Id) FROM resource_details");
	  
  while($row=mysql_fetch_array($res))
  {
	  $Lab_Id=$row['Lab_Id'];
	  echo '<option value="'.$Lab_Id.'">'.$Lab_Id.'</option>';
  }
	  ?>
        
      </select></td>
      </tr>
    <tr>
      <td height="30" colspan="6" align="left" scope="row" bgcolor="#6AB5FF"><a href="SearchResLab.php" class="reset">Reset |</a>
        <input name="Search" align="middle" type="submit" value="Search" /></td>
      </tr>
    <tr>
      <th height="24" colspan="2" align="left" scope="row">&nbsp;</th>
      <th height="24" colspan="3" align="left" scope="row"></th>
      <td colspan="2">&nbsp;</td>
    </tr>
  </table></form>
   <?php
   
	   if(isset($_POST['Search']))
	   {
	   $Resource_Id=$_POST['Resource_Id'];
$Lab_Id=$_POST['Lab_Id'];
	   }
	   
	   if($Resource_Id!="Select One"&&$Lab_Id!="Select One")
	   {
   $result=mysql_query("SELECT * FROM resource_details WHERE Resource_Id='$Resource_Id' AND Lab_Id='$Lab_Id'");
   
	   
if(mysql_num_rows($result)!=0)
   {
echo '<div style="overflow:scroll;">';
echo '<table width="957" border="1">

<tr>
<td width="94">Resource Id</td>
<td width="48">Lab Id</td>
<td width="46">Serial Number</td>
<td width="130">Functioning</td>
<td width="100">Brand Name</td>
<td width="158">Date Of Supplied</td>
<td width="137">Name Of Supplier</td>
<td width="93">Funding Source</td>

</tr>';
 
  while($row=mysql_fetch_array($result))
  {
    echo '<tr>';
    echo '<td width="94">'.$row['Resource_Id'].'</td>';
    echo '<td width="44">'.$row['Lab_Id'].'</td>';
    echo '<td width="65">'.$row['Serial_Number'].'</td>';
    echo '<td width="130">'.$row['Functioning'].'</td>';
    echo '<td width="100">'.$row['Brand_Name'].'</td>';
    echo '<td width="158">'.$row['Date_Of_Supplied'].'</td>';
    echo '<td width="137">'.$row['Name_Of_Supplier'].'</td>';
    echo '<td width="93">'.$row['Funding_Source'].'</td>';
  echo '</tr>';
  }
   echo '</table>';
  echo '</div>';

  }
  }
  
  ?>
 
</div>
</div>

<div class="rightmenu"> 
<?php
include_once "menu.php";
?>
 <?php
include_once "../footer.php";
?>
<?php
}
	  
	   ?>
</body>
</html>